import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToMany } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { School } from 'src/modules/school/entities/school.entity';
import { User } from 'src/modules/user/entities/user.entity';

enum TeacherStatus {
  PENDING = 'pending', // 审核中
  APPROVED = 'approved', // 通过
}

enum TeacherTitle {
  LECTURER = '讲师',
  ASSOCIATE_PROFESSOR = '副教授',
  PROFESSOR = '教授',
}

@Entity({name:'teacher'})
export class Teacher {
  @ApiProperty({ example: 1, description: '教师ID' })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ example: '张三', description: '教师姓名' })
  @Column()
  name: string;

  @ApiProperty({ enum: TeacherTitle, example: TeacherTitle.LECTURER, description: '教师职称' })
  @Column({
    type: 'enum',
    enum: TeacherTitle,
  })
  title: TeacherTitle;

  @ApiProperty({ enum: TeacherStatus, example: TeacherStatus.PENDING, description: '教师状态' })
  @Column({
    type: 'enum',
    enum: TeacherStatus,
    default: TeacherStatus.PENDING,
  })
  status: TeacherStatus;

  // @ApiProperty({ example: '学校实体', description: '所属学校' })
  // @ManyToOne(() => School, school => school.teachers)
  // school: School;

  /** 学生 */
  @ApiProperty({ example: '学生', description: '学生列表' })
  @OneToMany(() => User, user => user.advisor)
  students: User[];
}
